//
//  studipAppDelegate.m
//  studip
//
//  Created by Rafael Bugajewski on 04/21/10.
//  Copyright Juicy Cocktail 2010. All rights reserved.
//

#import "studipAppDelegate.h"
#import "LauncherViewTestController.h"
#import "JCDefaultStylesheet.h"
#import "CourseOverviewViewController.h"
#import "CourseDetailViewController.h"
#import "NewsOverviewController.h"
#import "FileViewController.h"
#import "FileDetailViewController.h"
#import "InboxOverviewController.h"
#import "InboxDetailViewController.h"

@implementation studipAppDelegate

- (void)dealloc
{
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
	[TTStyleSheet setGlobalStyleSheet:[[[JCDefaultStylesheet alloc] init] autorelease]];
	TTNavigator* navigator = [TTNavigator navigator];
	navigator.persistenceMode = TTNavigatorPersistenceModeAll;
	navigator.window = [[[UIWindow alloc] initWithFrame:TTScreenBounds()] autorelease];
	
	TTURLMap* map = navigator.URLMap;
	
	[map from:@"tt://launcherTest" toViewController:[LauncherViewTestController class]];
	[map from:@"fb://courses" toViewController:[CourseOverviewViewController class]];
	[map from:@"fb://courseDetails" toViewController:[CourseDetailViewController class]];
	[map from:@"fb://news" toViewController:[NewsOverviewController class]];
  [map from:@"fb://inbox" toViewController:[InboxOverviewController class]];
  [map from:@"fb://inboxDetails" toViewController:[InboxDetailViewController class]];
	[map from:@"fb://courseDetails/(initWithCourseId:)" toViewController:[CourseDetailViewController class]];
	[map from:@"fb://courseDetails/(initWithCourseId:)/files" toViewController:[FileViewController class]];
	[map from:@"fb://fileDetails/(initWithFileId:)" toViewController:[FileDetailViewController class]];
	
	
	//[map from:@"*" toViewController:[TTWebController class]];
	
	if (![navigator restoreViewControllers])
  {
		[navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://launcherTest"]];
	}
	
	return YES;
}

- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)URL
{
	[[TTNavigator navigator] openURLAction:[TTURLAction actionWithURLPath:URL.absoluteString]];
	return YES;
}

@end
